package com.minglead.crawler.base;

import lombok.Data;

/**
 * @author: clz
 * @date: 2024-06-11
 * @desc:entity 重新定义service层与controller层之间的数据交换；而不是简单的void boolean 这些
 * 类似：ActionResult，只是 ActionResult 更偏向 controller与前端直接的交互
 */
@Data
public class ActionResponse {
    private int code = 1;//正常、成功，非1不正常。表示失败

    private String message = "操作成功！";

    private Object data = null;

    private String ext;//扩展域，比较少用

    public ActionResponse() {
        this.code = 1;
        this.message = "操作成功！";
    }

    /**
     * 创建一个默认ActionResponse
     * @return
     */
    public static ActionResponse newInstance(){
        return new ActionResponse();
    }

    public static ActionResponse newInstanceOK(String message,Object data){
        return new ActionResponse(1,message,data);
    }

    public ActionResponse(int code, String message) {
        this.code = code;
        this.message = message;
    }
    public ActionResponse(int code, String message, Object data){
        this.code = code;
        this.message = message;
        this.data=data;
    }
}
